//ITMD536 Software Testing and Maintenance.
//Final project <group assignment>
//Author: Wanglei ID:A20479012
//Face recognition system main program.
#include<iostream>
#include <cstring>
#include "Process.hpp"

using namespace std;
static const int param_size = 2;

//Description of program operation and command line parameters.
void usage_print(void){
    string usage_string;
    usage_string = R"(face routinue cmd line parameters error.)";
    cout << usage_string << endl;
    usage_string = R"(excute the run.sh, register.sh, show.sh, clear.sh script, please check the README.md file for details.)";
    cout << usage_string << endl;
}

void runBusinessClassification(char *param, char *name, char *username){
     //Command line parameter parsing.
    //-clr for clean, -reg for register, -run for run, -show for show.
    if(0 == strcmp("-run", param)){
        //cout << "run-> " << "file name: " << name << endl;
        faceRecognition(name);
    }
    else if (0 == strcmp("-reg", param)){
        //cout << "register-> " << "file name: " << name << " user-name: " << username << endl;
        if(nullptr == username){
            usage_print(); 
            return;
        }

        faceRegister(name, username);
    }
    else if (0 == strcmp("-clr", param)){
        //cout << "clear -> " << "registered user name: " << name << endl;
        faceRegClear(name);
    }
    else if (0 == strcmp("-show", param)){
        //cout << "show-> " << "not need name." << endl;
        faceRegShow();
    }
}

//Program entry function.
int main(int argc, char** argv){
    //Command line parameter judgment
    if(param_size > argc || 4 < argc){
        usage_print(); return 0;
    }else if(nullptr == argv[1]){
        usage_print(); return 0;
    }

    //cout << "debug: " << argv[1] << endl;
    runBusinessClassification(argv[1], argv[2], argv[3]);
    return 0;
}
